package com.sbox.album;

import com.sbox.album.model.AlbumContext;
import com.sbox.album.model.AlbumManager;
import com.sbox.album.model.PictureInfo;
import com.sbox.util.AlbumConst;
import com.sbox.util.AlbumLog;
import com.sbox.widget.PicGridView;
import com.sbox.widget.TitleBar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

public class ImportActivity extends Activity {	
	private TitleBar mTitleBar = null;
	private PicGridView mGridView = null;
	
	private View.OnClickListener mSelectListener = new View.OnClickListener() {		
		@Override
		public void onClick(View v) {
			PictureInfo[] selPics = mGridView.getSelectedPictures();
			if( selPics == null || selPics.length == 0 )
				return;
		
			AlbumManager.importPictures(selPics, AlbumContext.getAlbum());
			ImportActivity.this.finish();
		}
	};
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_import);
     
        mTitleBar = (TitleBar)findViewById(R.id.import_title_bar);
        mTitleBar.getButton2().setImageResource(R.drawable.btn_select);
        mTitleBar.getButton2().setOnClickListener(mSelectListener);
        
        mGridView = (PicGridView)findViewById(R.id.import_grid);
        //mGridView.setOnItemClickListener(mGridClickListener);
    }
	
	@Override
	public void onResume() {
		super.onResume();
		
		AlbumContext.getCacheManager().clearCache();
		mGridView.loadImages(AlbumConst.SYSTEM_IMAGE_PATH);
	}	
	
	@Override
	public void onStop() {
		super.onStop();		
		
		AlbumLog.info("ImportActivity.onStop.");
	}
	
}
